Initially for testing I connected the module directly to my PC via a USB to RS232 converter, then by using a suitable terminal program fired HEX packets at the module in order to observe the results. I used the some terminal software called HTerm that I found very good for this purpose, but many others are available. HTerm Link: http://www.der-hammer.info/terminal/
To control the player correctly formatted command packets must be sent to the module. These packets are made up of 9 elements as shown below:
To play track 1 in folder 1 we would send:
7E FF 06 0F 00 01 01 FE EA EF
This breaks down as:
7E = Start of Packet
FF = Always set to FF
06 = Number of Words in the command words
0F = Command for "Specify file and folder to play"
00 = State if serial feedback is needed
01 = Directory Number (0 - 63)Hex, (0 - 99)Dec
01 = File number (00-FF)Hex, (0 - 255)Dec
EF = Checksum Hi
EA = Checksum Lo
EF = End of Packet
A description that explained the creation of the checksum was very hard to find but eventually by looking around online the following method was located.
The start and stop are not included in the checksum, but if the other elements are added together as below:
FF + 06 + 0F + 00 + 01 + 01 = 116
Then by subtracting this result from zero the Hi and Lo checksums can be calculated.
0 - 116 = FEEA (Hi = FE) / (Lo = EA)
When the packet is sent, if you are monitoring the reply from the module then you see the following:
7F FF 06 3D 00 00 10 FE AE EF
Which according to the manual a CMD value of 3D is described as "Stay", something may have been lost in translation here. This packet arrives when the module completes the playback of the selected mp3 so could be used in order to indicate when playback has ended.
If however we structured the message as below, substituting the 5th word with a 01 instead of 00 in order to request feedback:
7E FF 06 0F 01 01 01 FE E9 EF (note that the checksum has also changed)
Then when the packet is sent, the module would reply:
7E FF 06 41 00 00 00 FE BA EF
7E FF 06 3D 00 00 10 FE AE EF
According to the manual the 41 in the first packet is the described as "Reply" the first packet arrives the moment the command is sent to the module and the second packet is much as above arriving when the mp3 playback ends.
Other command examples are:
play track 2 in folder 1
7E FF 06 0F 00 01 02 FE E9 EF
play track 3 in folder 1
7E FF 06 0F 00 01 03 FE E8 EF
play track 1 in folder 2
7E FF 06 0F 00 02 01 FE E9 EF
volume to 15 out of 30
7E FF 06 06 00 00 0F FE Ed EF
A BUSY flag is also supplied on the module that indicates when the mp3 player is active, this can also be used in order to identify if a control command can be sent, this line is used on the example program suppled as it provides an easier way in order to monitor the mp3 modules operation.
The DFPlayer Interface Circuit
|
Connecting to the circuit is quite striate forward, as described above R1 and R2 provide protection for the microcontroller running at 3.3V. The 5V supply powers the module and for this suitable de-coupling is included.
|
|